import { uploadFileApi } from '../../../apis/uploadApi';
const imgBaseUrl = import.meta.env.VITE_BASE_FILE_SRC;

const editorConfig = { placeholder: '请输入内容...', MENU_CONF: {} };

editorConfig.MENU_CONF['uploadImage'] = {
    // 自定义上传
    async customUpload(file, insertFn) {
      // JS 语法
      const base = await uploadFileApi(file);
      insertFn(imgBaseUrl + base, '', '');
    },
  };
  // 插入图片
  editorConfig.MENU_CONF['insertImage'] = {
    onInsertedImage(imageNode) {
      // JS 语法
      if (imageNode == null) return;
  
      const { src, alt, url, href } = imageNode;
    },
  };
  // 编辑图片
  editorConfig.MENU_CONF['editImage'] = {
    onUpdatedImage(imageNode) {
      // JS 语法
      if (imageNode == null) return;
      const { src, alt, url } = imageNode;
    },
  };

export default editorConfig;